﻿using System;
using System.IO;
using System.Text;

namespace SaveAssist
{
	// Token: 0x020002FF RID: 767
	public class BlockHeader
	{
		// Token: 0x060012CC RID: 4812 RVA: 0x000989E0 File Offset: 0x00096BE0
		public virtual void SetHeader(string _tagName, int _version, long _pos, long _size)
		{
			this.tagName = _tagName;
			this.tag = BlockHeader.ChangeStringToByte(this.tagName);
			this.version = _version;
			this.pos = _pos;
			this.size = _size;
		}

		// Token: 0x060012CD RID: 4813 RVA: 0x00098A10 File Offset: 0x00096C10
		public virtual bool SaveHeader(BinaryWriter writer)
		{
			if (this.tag == null)
			{
				return false;
			}
			writer.Write(this.tag);
			writer.Write(this.version);
			writer.Write(this.pos);
			writer.Write(this.size);
			return true;
		}

		// Token: 0x060012CE RID: 4814 RVA: 0x00098A50 File Offset: 0x00096C50
		public virtual bool LoadHeader(BinaryReader reader)
		{
			this.tag = reader.ReadBytes(128);
			this.tagName = BlockHeader.ChangeByteToString(this.tag);
			this.version = reader.ReadInt32();
			this.pos = reader.ReadInt64();
			this.size = reader.ReadInt64();
			return true;
		}

		// Token: 0x060012CF RID: 4815 RVA: 0x00098AA4 File Offset: 0x00096CA4
		public static int GetBlockHeaderSize()
		{
			return 148;
		}

		// Token: 0x060012D0 RID: 4816 RVA: 0x00098AAC File Offset: 0x00096CAC
		public static byte[] ChangeStringToByte(string _tagName)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(_tagName);
			if (bytes.GetLength(0) > 128)
			{
				return null;
			}
			byte[] array = new byte[128];
			Buffer.BlockCopy(bytes, 0, array, 0, bytes.GetLength(0));
			return array;
		}

		// Token: 0x060012D1 RID: 4817 RVA: 0x00098AF4 File Offset: 0x00096CF4
		public static string ChangeByteToString(byte[] _tag)
		{
			return Encoding.UTF8.GetString(_tag);
		}

		// Token: 0x04001899 RID: 6297
		protected const int tagSize = 128;

		// Token: 0x0400189A RID: 6298
		public string tagName = string.Empty;

		// Token: 0x0400189B RID: 6299
		public byte[] tag;

		// Token: 0x0400189C RID: 6300
		public int version;

		// Token: 0x0400189D RID: 6301
		public long pos;

		// Token: 0x0400189E RID: 6302
		public long size;
	}
}
